home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <hamdefs.h>
- extern int have_selected,drive_to_use,factor;
-
- static char intlv_table[512];
- static char disk_buffer[17*512];
-
- #define SECTORS 17
-
- rfw()
- /* read, format, write */
- {
- struct {unsigned int ax,bx,cx,dx,si,di,ds,es;}send,rec;
- unsigned int cylinder,head,
- cyl_max, head_max;
- char temp[80];
- unsigned percent;
-
- int pr,pc;
-
- percent=0;
-
- if(!have_selected) {
- errmsg("You must select which drive to use.....");
- return 0;
- }
-
- build(factor);
- segread(&send.si);
- send.es=send.ds;
- send.ax=0x0800;
- send.bx=send.cx=0;
- send.dx=drive_to_use;
- if(1&sysint13(&send,&rec)) {
- atputsa(2,25,"Unable to address hard disk(s)",NORMAL|HILITE);
- beep();
- return 1;
- }
- head_max=rec.dx>>8;
- cyl_max=((rec.cx & 0xc0)<<2) + (rec.cx>>8);
-
- atputsa(3,10,"READ FORMAT WRITE HEAD CYLINDER",NORMAL|HILITE);
- atputsha(-1,-1," Percent complete: ");
- findcsr(&pr,&pc);
- for(cylinder=0; cylinder <= cyl_max; cylinder++) {
- locate(4,41);
- sprintf(temp,"%d",cylinder);
- vputs(temp);
- percent=(((unsigned)100*cylinder)/cyl_max);
- sprintf(temp,"%d",percent);
- atputsha(pr,pc,temp);
- for(head=0; head <= head_max; head++) {
- locate(4,33);
- vputc(head+'0');
-
- /* read cylinder */
- clrblk(4,10,4,30);
- atputsha(4,11,"\315\315");
- send.ax= 0x0200 + SECTORS;
- send.bx= disk_buffer;
- send.cx= (cylinder<<8) + ((cylinder&0x300)>>2) + 1;
- send.dx= (head<<8) + drive_to_use;
-
- if(1 & sysint13(&send,&rec)) {
- reset_disk();
- continue;
- }
-
- if(kbhit()) {
- if(inkeyi()==3)
- terminate();
- clrkey();
- }
-
- /* format cylinder: */
-
- clrblk(4,10,4,30);
- atputsha(4,18,"\315\315");
- send.ax=0x0500 + factor;
- send.bx=intlv_table;
-
- if(1 & sysint13(&send,&rec)) {
- reset_disk();
- continue;
- }
-
- /* write cylinder: */
-
- clrblk(4,10,4,30);
- atputsha(4,25,"\315\315");
- send.ax= 0x0300 + SECTORS;
- send.bx= disk_buffer;
-
- if(1 & sysint13(&send,&rec)) {
- reset_disk();
- }
- }
- }
- cursor(TRUE);
- return 0;
- }
-
- reset_disk()
- {
- struct {int ax,bx,cx,dx,si,di,ds,es;}temp;
-
- temp.ax=0;
- temp.dx=drive_to_use;
- segread(&temp.si);
- sysint13(&temp,&temp);
- }
-
- build(factor)
- int factor;
- {
- int i,cur;
-
- for(i=cur=0;i<17;i++,cur += factor) {
- if(cur>17)
- cur -= 17;
- intlv_table[(2*cur)+1]=i+1;
- }
- }
-
- terminate()
- {
- intrrest(0x23);
- locate(22,2);
- vputs("CTRL-C aborts the program at any time");
- locate(23,0);
- cursor(TRUE);
- exit(0);
- }
-